<html>
	<head>
		<title>DatingBook</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		
		<link rel="stylesheet" href="css/jquery.mobile-1.0.min.css" />
		<script type="text/javascript" src="js/jquery.min.js"></script>
		<script type="text/javascript" src="js/jquery.mobile-1.0.min.js"></script>
		
		<script type="text/javascript" src="js/tab1.js"></script>
    </head>

	<body dir="rtl">
		<div id="DBM_BannerTop" align="center" style="background-image: url('images/top_bg.png'); background-repeat: repeat-x" >
			<img alt='' src="images/datingbook.png" style="margin-top: 10px; margin-bottom: 9px" />
		</div>

		<table id="DBM_NeedLogin" width="100%" cellpadding="0" cellspacing="0">
			<tr style="font-family: Arial, Helvetica, sans-serif; font-size: 22px; color: #000080;" bgcolor="#EEEEEE">
				<td align="center" valign="middle" height="40" colspan="3">
					Бо лимцо ба фейсбук бехинм
				</td>
			</tr>
			<tr bgcolor="#EEEEEE">
				<td align="center" colspan="3">
					<img alt='' src="images/f.png" onclick="loginUser();" />
				</td>
			</tr>
			<tr bgcolor="#EEEEEE">
				<td align="center" valign="bottom" height="105" colspan="3">
					<img alt='' src="images/para.png" />
				</td>
			</tr>
		</table>

		<div id="DBM_Work" style="display: none; background-color: #EEEEEE">
			<table width="100%" cellpadding="1" cellspacing="1">
				<tr style="font-family: Arial, Helvetica, sans-serif; font-size: 22px; color: #000080;">
					<td align="center" valign="middle" height="30" colspan="2">
						Что будем искать?
					</td>
				</tr>
				<tr>
					<td align="center">
						<select id="DBMGender">
							<option value="">Все</option>
							<option value="boy">Бен</option>
							<option value="girl">Бат</option>
						</select></td>
					<td align="center">
						<select id="Select2">
							<option>хз</option>
							<option>Option2</option>
							<option>Option3</option>
							<option>Option4</option>
						</select>
					</td>
				</tr>
				<tr>
					<td align="center">
						<select id="DBMAgeFrom">
							<option value="">все</option>
						</select>
					</td>
					<td align="center">
						<select id="DBMAgeTo">
							<option value="">все</option>
						</select>
					</td>
				</tr>
				<tr align="center" >
					<td colspan="2" style="padding-right: 25%; padding-left: 25%">
						<input id="Button1" type="button" data-icon="star" value="Хипус" onclick="getUsers();" />
					</td>
				</tr>
			</table>
	
			<div id="DBM_Users" align="center">
			</div>
		</div>
	
		<div id="DBM_BannerBot">
			<table width="100%" cellpadding="0" cellspacing="0">
				<tr>
					<td align="center" valign="middle" height="44" style="background-image: url('images/btn1_bg.png');
						background-repeat: repeat-x">
						<a href="">
							<img alt='' src="images/btn1.png" border="0" /></a>
					</td>
					<td align="center" valign="middle" height="44" style="background-image: url('images/btn1_bg.png');
						background-repeat: repeat-x">
						<a href="">
							<img alt='' src="images/btn2.png" border="0" /></a>
					</td>
					<td align="center" valign="middle" height="44" style="background-image: url('images/btn3_bg.png');
						background-repeat: repeat-x">
						<a href="">
							<img alt='' src="images/btn3.png" border="0" /></a>
					</td>
				</tr>
			</table>
		</div>

		<script src="js/phonegap-1.2.0.js"></script>
		<script src="js/pg-plugin-fb-connect.js"></script>
		<script src="js/facebook_js_sdk.js"></script>
        
		<script>
			var _uid;
			var _link = "http://www.scoreplug.com/datingbook/";
			var _tab1 = {type: ""};
			
			if (typeof PhoneGap == 'undefined') alert('PhoneGap variable does not exist. Check that you have included phonegap.js correctly');
            if (typeof PG == 'undefined') alert('PG variable does not exist. Check that you have included pg-plugin-fb-connect.js correctly');
            if (typeof FB == 'undefined') alert('FB variable does not exist. Check that you have included the Facebook JS SDK file.');

       		function authStatusChange(response) {
    			if(response.session && response.session.access_token) {
    	            FB.Event.unsubscribe('auth.statusChange', authStatusChange);
    				
    	            getId(response.session.uid);
    				document.getElementById("DBM_NeedLogin").style.display = "none";
    				document.getElementById("DBM_Work").style.display = "";
    				initLast();
    			}
            }
            
       		function getLoginStatus() {
       			FB.getLoginStatus(function(response) {
       				if (response.session) {
       					alert('logged in');
       				}
       			});
       		}
       		
    		function initLast() {
    			initAge(document.getElementById("DBMAgeFrom"));
    			initAge(document.getElementById("DBMAgeTo"));
    		}

    		function initAge(objSel) {
    			objSel.options.length = 1;
    			for(var i = 18; i < 60; i++)
    				objSel.options[objSel.options.length] = new Option(i, i);
    			objSel.options[objSel.options.length] = new Option("60+", "60+");
    		}

    		function getId(fbUid) {
    			$.post(_link + "post_data.axd?type=get_id", { id: fbUid },
    				function (response) {
//    				alert(JSON.stringify(response));
    					_uid = response.data.uid;
//    					getUsers();
    				});
    		}
            
            
//				C:\Program Files\Java\jre7\bin           
//            keytool -exportcert -alias androiddebugkey -keystore "C:\Users\SlavaV\.android\debug.keystore" | "C:\Adobe\OpenSSL\bin\openssl" sha1 -binary |"C:\Adobe\OpenSSL\bin\openssl" base64 
//            keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64

//"C:\Program Files\Java\jre7\bin\keytool" -exportcert -alias androiddebugkey -keystore "C:\Eclipse\workspace\Dating\.settings\keys" | "C:\Adobe\OpenSSL\bin\openssl" sha1 -binary |"C:\Adobe\OpenSSL\bin\openssl" base64
// NfgDlIG7XWJzUZRUL+bZySrMX1Q=
            
//"C:\Program Files\Java\jre6\bin\keytool" -exportcert -alias androiddebugkey -keystore ~/.android/release.keystore | E:\Adobe\OpenSSL\bin\openssl sha1 -binary | E:\Adobe\OpenSSL\bin\openssl base64
//Yike/sUHS5H1WXNJ/lT+WKq1rdA=	
	
	
            function loginUser() {
				FB.login(function(response) {},
                	{ perms: "read_stream,user_birthday,user_location,user_about_me,user_interests,user_activities,user_photos,user_photo_video_tags,user_religion_politics,user_education_history,user_work_history,email,offline_access" }
                );
            }
            
    		function getUsers() {
    			$('#DBM_Users').html('');
    			$('#DBM_Users').append("<img src='images/loader.gif'/>");
    			
    			$.post(_link + "post_data.axd?type=get_six", {
    				id: _uid,
    				page: 1,
    				type: '',
    				//param1: _search_params[0],
    				param2: $("#DBMAgeFrom").value,
    				param21: $("#DBMAgeTo").value,
    				param3: $("#DBMGender").value
    				//				param4: _search_params[4],
    				//				param5: _search_params[5],
    				//				param6: _search_params[6]
    			}, function (result) {
    				$('#DBM_Users').html('');
    				if(result.data && result.data.length)
    					try {
    						ParsingAnswerThree(result.data);
    					}
    				catch(e) {alert(e)}
    			});
    		}

    		function ParsingAnswerThree(users) {
    			if(users.length) {
    				for(var i = 0; i < 3; i++) {
    					if(users.length > i) {
    						var div = createUserInfoDiv(users[i]);
    						$('#DBM_Users').append(div);
    					}
    				}
    			}
    		}

    		var _devReady;
        document.addEventListener('deviceready', function() {
        	if(_devReady == undefined) {
					  _devReady = 1;
	
					  PhoneGap.addConstructor(function() {
					        PhoneGap.addPlugin("demo", new DemoPlugin());
					    });    

					    $('#send').bind('click', function () {        
					        //var plugin = new DemoPlugin();
					        window.plugins.demo.sendSMS(function () { 
					           alert('Message sent successfully'); 
					        },
					        function (e) {
					            alert('Message Failed:' + e);
					        },
					        $('#phone').val(), 
					        $('#message').val());
					    }); 
					  
//            FB.init({ appId: '248472455213149', nativeInterface: PG.FB });
//            FB.Event.subscribe('auth.statusChange', authStatusChange); 
//          FB.logout();
				}
            }, false);
        </script>
	</body>
</html>